Skip to content

Conversation

dabrt
Copy link
Contributor

@dabrt dabrt commented Jun 26, 2025

Question Answer
JIRA Ticket IBX-9060
Versions 4.6+
Edition all

Document revamped notifications

Checklist

  • Text renders correctly
  • Text has been checked with vale
  • Description metadata is up to date

@dabrt dabrt assigned tbialcz and unassigned tbialcz Sep 8, 2025
@dabrt dabrt requested a review from tbialcz September 8, 2025 12:51
Copy link

github-actions bot commented Sep 9, 2025

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/back_office/notifications/src/Notification/ListRenderer.php


code_samples/back_office/notifications/src/Notification/ListRenderer.php

docs/administration/back_office/notifications.md@94:```php
docs/administration/back_office/notifications.md@95:[[= include_file('code_samples/back_office/notifications/src/Notification/ListRenderer.php') =]]
docs/administration/back_office/notifications.md@96:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Notification;
006⫶
007⫶use Ibexa\Contracts\Core\Repository\Values\Notification\Notification;
008⫶use Ibexa\Core\Notification\Renderer\NotificationRenderer;
009⫶use Ibexa\Core\Notification\Renderer\TypedNotificationRendererInterface;
010⫶use Symfony\Component\HttpFoundation\RequestStack;
011⫶use Symfony\Component\Routing\RouterInterface;
012⫶use Twig\Environment;
013⫶
014⫶class ListRenderer implements NotificationRenderer, TypedNotificationRendererInterface
015⫶{
016⫶ protected Environment $twig;
017⫶
018⫶ protected RouterInterface $router;
019⫶
020⫶ protected RequestStack $requestStack;
021⫶
022⫶ public function __construct(Environment $twig, RouterInterface $router, RequestStack $requestStack)
023⫶ {
024⫶ $this->twig = $twig;
025⫶ $this->router = $router;
026⫶ $this->requestStack = $requestStack;
027⫶ }
028⫶
029⫶ public function render(Notification $notification): string
030⫶ {
031⫶ $templateToExtend = '@ibexadesign/account/notifications/list_item.html.twig';
032⫶ $currentRequest = $this->requestStack->getCurrentRequest();
033⫶ if ($currentRequest && $currentRequest->attributes->getBoolean('render_all')) {
034⫶ $templateToExtend = '@ibexadesign/account/notifications/list_item_all.html.twig';
035⫶ }
036⫶
037⫶ return $this->twig->render('@ibexadesign/notification.html.twig', [
038⫶ 'notification' => $notification,
039⫶ 'template_to_extend' => $templateToExtend,
040⫶ ]);
041⫶ }
042⫶
043⫶ public function generateUrl(Notification $notification): ?string
044⫶ {
045⫶ if (array_key_exists('content_id', $notification->data)) {
046⫶ return $this->router->generate('ibexa.content.view', [
047⫶ 'contentId' => $notification->data['content_id'],
048⫶ ]);
049⫶ }
050⫶
051⫶ return null;
052⫶ }
053⫶
054⫶ public function getTypeLabel(): string
055⫶ {
056⫶ return /** @Desc("Workflow stage changed") */
057⫶ $this->translator->trans(
058⫶ 'workflow.notification.stage_change.label',
059⫶ [],
060⫶ 'ibexa_workflow'
061⫶ );
062⫶ }
063⫶}


code_samples/back_office/notifications/src/Notification/MyRenderer.php


code_samples/back_office/notifications/src/Notification/MyRenderer.php

docs/administration/back_office/notifications.md@70:```php
docs/administration/back_office/notifications.md@71:[[= include_file('code_samples/back_office/notifications/src/Notification/MyRenderer.php') =]]
docs/administration/back_office/notifications.md@72:```
docs/administration/back_office/notifications.md@72:```php
docs/administration/back_office/notifications.md@73:[[= include_file('code_samples/back_office/notifications/src/Notification/MyRenderer.php') =]]
docs/administration/back_office/notifications.md@74:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Notification;
006⫶
007⫶use Ibexa\Contracts\Core\Repository\Values\Notification\Notification;
008⫶use Ibexa\Core\Notification\Renderer\NotificationRenderer;

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Notification;
006⫶
007⫶use Ibexa\Contracts\Core\Repository\Values\Notification\Notification;
008⫶use Ibexa\Core\Notification\Renderer\NotificationRenderer;
009⫶use Symfony\Component\Routing\RouterInterface;
010⫶use Twig\Environment;
011⫶
012⫶class MyRenderer implements NotificationRenderer
013⫶{
014⫶ public function __construct(
015⫶ protected Environment $twig,
016⫶ protected RouterInterface $router
017⫶ ) {
018⫶ }
019⫶
020⫶ public function render(Notification $notification): string
021⫶ {
022⫶ return $this->twig->render('@ibexadesign/notification.html.twig', ['notification' => $notification]);
009⫶use Ibexa\Core\Notification\Renderer\TypedNotificationRendererInterface;
010⫶use Symfony\Component\Routing\RouterInterface;
011⫶use Twig\Environment;
012⫶
013⫶class MyRenderer implements NotificationRenderer, TypedNotificationRendererInterface
014⫶{
015⫶ protected Environment $twig;
016⫶
017⫶ protected RouterInterface $router;
018⫶
019⫶ public function __construct(Environment $twig, RouterInterface $router)
020⫶ {
021⫶ $this->twig = $twig;
022⫶ $this->router = $router;
023⫶    }
024⫶
023⫶    }
024⫶
025⫶    public function generateUrl(Notification $notification): ?string
025⫶    public function render(Notification $notification): string
026⫶    {
026⫶    {
027⫶        if (array_key_exists('content_id', $notification->data)) {
028⫶ return $this->router->generate('ibexa.content.view', ['contentId' => $notification->data['content_id']]);
029⫶ }
030⫶
031⫶ return null;
032⫶ }
033⫶}
027⫶        return $this->twig->render('@ibexadesign/notification.html.twig', [
028⫶ 'notification' => $notification,
029⫶ 'template_to_extend' => $templateToExtend,
030⫶ ]);
031⫶ }
032⫶
033⫶ public function generateUrl(Notification $notification): ?string
034⫶ {
035⫶ if (array_key_exists('content_id', $notification->data)) {
036⫶ return $this->router->generate('ibexa.content.view', ['contentId' => $notification->data['content_id']]);
037⫶ }
038⫶
039⫶ return null;
040⫶ }
041⫶
042⫶ }
043⫶
044⫶ public function getTypeLabel(): string
045⫶ {
046⫶ return /** @Desc("Workflow stage changed") */
047⫶ $this->translator->trans(
048⫶ 'workflow.notification.stage_change.label',
049⫶ [],
050⫶ 'ibexa_workflow'
051⫶ );
052⫶ }
053⫶}


code_samples/back_office/notifications/templates/themes/admin/notification.html.twig



code_samples/back_office/notifications/templates/themes/admin/notification.html.twig

docs/administration/back_office/notifications.md@76:```html+twig
docs/administration/back_office/notifications.md@77:[[= include_file('code_samples/back_office/notifications/templates/themes/admin/notification.html.twig') =]]
docs/administration/back_office/notifications.md@78:```
docs/administration/back_office/notifications.md@78:```html+twig
docs/administration/back_office/notifications.md@79:[[= include_file('code_samples/back_office/notifications/templates/themes/admin/notification.html.twig') =]]
docs/administration/back_office/notifications.md@80:```


001⫶{% extends '@ibexadesign/account/notifications/list_item.html.twig' %}
001⫶{% extends template_to_extend %}
002⫶
003⫶{% trans_default_domain 'custom_notification' %}
004⫶
005⫶{% set wrapper_additional_classes = 'css-class-custom' %}
006⫶
007⫶{% block icon %}
008⫶ <span class="type__icon">
009⫶ <svg class="ibexa-icon ibexa-icon--review">
002⫶
003⫶{% trans_default_domain 'custom_notification' %}
004⫶
005⫶{% set wrapper_additional_classes = 'css-class-custom' %}
006⫶
007⫶{% block icon %}
008⫶ <span class="type__icon">
009⫶ <svg class="ibexa-icon ibexa-icon--review">
010⫶            <use xlink:href="{{ ibexa_icon_path('visibility') }}"></use>
010⫶            <use xlink:href="{{ ibexa_icon_path('view') }}"></use>
011⫶        </svg>
012⫶ </span>
013⫶{% endblock %}
014⫶
015⫶{% block notification_type %}
016⫶ <span class="type__text">
017⫶ {{ 'Notice'|trans|desc('Notice') }}
018⫶ </span>
019⫶{% endblock %}
020⫶
021⫶{% block message %}
022⫶ {% embed '@ibexadesign/ui/component/table/table_body_cell.html.twig' with { class: 'ibexa-notifications-modal__description' } %}
023⫶ {% block content %}
024⫶ <p class="description__text">{{ notification.data.content_name }} {{ notification.data.message }}</p>
025⫶ {% endblock %}
026⫶ {% endembed %}
027⫶{% endblock %}


code_samples/notifications/Src/Query/search.php

011⫶        </svg>
012⫶ </span>
013⫶{% endblock %}
014⫶
015⫶{% block notification_type %}
016⫶ <span class="type__text">
017⫶ {{ 'Notice'|trans|desc('Notice') }}
018⫶ </span>
019⫶{% endblock %}
020⫶
021⫶{% block message %}
022⫶ {% embed '@ibexadesign/ui/component/table/table_body_cell.html.twig' with { class: 'ibexa-notifications-modal__description' } %}
023⫶ {% block content %}
024⫶ <p class="description__text">{{ notification.data.content_name }} {{ notification.data.message }}</p>
025⫶ {% endblock %}
026⫶ {% endembed %}
027⫶{% endblock %}


code_samples/notifications/Src/Query/search.php

docs/search/criteria_reference/notification_datecreated_criterion.md@19:```php hl_lines="19"
docs/search/criteria_reference/notification_datecreated_criterion.md@20:[[= include_file('code_samples/notifications/Src/Query/search.php') =]]
docs/search/criteria_reference/notification_datecreated_criterion.md@21:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶use Ibexa\Contracts\Core\Repository\Values\NotificationQuery;
006⫶
007⫶$repository = $this->getRepository();
008⫶$notificationService = $repository->getNotificationService();
009⫶$query = new NotificationQuery([], 0, 25);
010⫶
011⫶$query->addCriterion(new Type('Workflow:Review'));
012⫶$query->addCriterion(new Status(['unread']));
013⫶
014⫶$from = new \DateTimeImmutable('-7 days');
015⫶$to = new \DateTimeImmutable();
016⫶
017⫶$query->addCriterion(new DateCreated($from, $to));
018⫶
019❇️$notificationList = $notificationService->findNotifications($query);

docs/search/criteria_reference/notification_status_criterion.md@18:```php hl_lines="14"
docs/search/criteria_reference/notification_status_criterion.md@19:[[= include_file('code_samples/notifications/Src/Query/search.php') =]]
docs/search/criteria_reference/notification_status_criterion.md@20:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶use Ibexa\Contracts\Core\Repository\Values\NotificationQuery;
006⫶
007⫶$repository = $this->getRepository();
008⫶$notificationService = $repository->getNotificationService();
009⫶$query = new NotificationQuery([], 0, 25);
010⫶
011⫶$query->addCriterion(new Type('Workflow:Review'));
012⫶$query->addCriterion(new Status(['unread']));
013⫶
014❇️$from = new \DateTimeImmutable('-7 days');
015⫶$to = new \DateTimeImmutable();
016⫶
017⫶$query->addCriterion(new DateCreated($from, $to));
018⫶
019⫶$notificationList = $notificationService->findNotifications($query);

docs/search/criteria_reference/notification_type_criterion.md@18:```php hl_lines="13"
docs/search/criteria_reference/notification_type_criterion.md@19:[[= include_file('code_samples/notifications/Src/Query/search.php') =]]
docs/search/criteria_reference/notification_type_criterion.md@20:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶use Ibexa\Contracts\Core\Repository\Values\NotificationQuery;
006⫶
007⫶$repository = $this->getRepository();
008⫶$notificationService = $repository->getNotificationService();
009⫶$query = new NotificationQuery([], 0, 25);
010⫶
011⫶$query->addCriterion(new Type('Workflow:Review'));
012⫶$query->addCriterion(new Status(['unread']));
013❇️
014⫶$from = new \DateTimeImmutable('-7 days');
015⫶$to = new \DateTimeImmutable();
016⫶
017⫶$query->addCriterion(new DateCreated($from, $to));
018⫶
019⫶$notificationList = $notificationService->findNotifications($query);

Download colorized diff

Copy link
Contributor

@mnocon mnocon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Please have a look at the code highlights - I think they have moved after some changes to the code sample.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of these icons seem unused?


### PHP

```php hl_lines="19"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```php hl_lines="19"
```php hl_lines="14-15 17"

I'd highlight the line where the criterion is created


### PHP

```php hl_lines="14"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```php hl_lines="14"
```php hl_lines="12"


### PHP

```php hl_lines="13"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```php hl_lines="13"
```php hl_lines="11"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants